from urllib.parse import quote_plus

import pandas as pd
import requests
from sqlalchemy import create_engine

"""数据库链接 pandas方法"""


def read_fandan_mysql_zhengshi():
    user = 'live_data'
    password = quote_plus('CJMg2tsHg7sj6bo0UTKq0a4T!fPDpJ')
    # passwd ='merchantsasd123!@%&'https://fxg.jinritemai.com/ecomauth/loginv1/get_login_subject?
    host = 'rm-bp17r99475xuauk63yo.mysql.rds.aliyuncs.com'
    # port1 ='3306'
    dbname2 = 'live_data'
    engine2 = create_engine(f"mysql+pymysql://{user}:{password}@{host}:3306/{dbname2}?charset=utf8")
    return engine2



data_info = pd.read_sql("select * from live_data.xhs_user_info where win='A'",read_fandan_mysql_zhengshi())

data_list = [data_info.loc[i].to_dict() for i in data_info.index.values]
for i in data_list:
    print(i)

    data = {
        "env":0,
        "biztype":1,
        "xhs_account":i["spider_user_id"]
    }

    url = "http://127.0.0.1:5006/xhs/unbind/DeleteUser"

    data = requests.post(url,json=data)
    print(data.text)